<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>呼吸灯</title>
  </head>
  <style>
    * {
      box-sizing: border-box;
    }
    .outer {
      width: 300px;
      height: 500px;
      margin: auto;
      background-color: #000;
    }
    .inner {
      height: 300px;
      width: 300px;
      padding: 60px;
    }
    .waimian {
      height: 100%;
      border-radius: 50%;
      border: 3px solid #fff;
      padding: 30px;
    }
    .limian {
      height: 100%;
      border-radius: 50%;
      border: 10px solid #fff;
    }
    .text {
      width: 300px;
      height: 200px;
      color: #fff;
      text-align: center;
    }
  </style>
  <body>
    <div class="outer">
      <div class="inner">
        <div class="waimian">
          <div class="limian"></div>
        </div>
      </div>
      <div class="text">HI !</div>
    </div>
  </body>
  <script>
    var inner = document.querySelector(".inner");
    var waimian = inner.querySelector(".waimian");
    var limian = waimian.querySelector(".limian");
    console.log(inner, waimian, limian);
    var pad = 30;
    var inpad = 60;
    var flag = true;
    var flagsec = true;
    function padd() {
      if (flag == true && flagsec == true) {
        // inner.style.padding = pad + "px";
        waimian.style.padding = pad + "px";
        pad++;
        if (pad == 50) {
          flag = false;
        }
      } else if (flag == false && flagsec == true) {
        // inner.style.padding = pad + "px";
        waimian.style.padding = pad + "px";
        pad--;
        if (pad == 30) {
          flag = true;
          flagsec = false;
        }
      } else if (flag == true && flagsec == false) {
        waimian.style.padding = pad + "px";
        inner.style.padding = inpad + "px";
        inpad--;
        pad++;
        if (pad == 50) {
          flag = false;
          flagsec = false;
        }
      } else if (flag == false && flagsec == false) {
        waimian.style.padding = pad + "px";
        inner.style.padding = inpad + "px";
        inpad++;
        pad--;
        if (pad == 30) {
          flag = true;
          flagsec = true;
        }
      }
    }
    setInterval(function () {
      padd();
    }, 200);
  </script>
</html>
